package com.greystripe.sdk;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore.Images.Media;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;

final class ba
  implements Runnable
{
  ba(GSFullscreenActivity paramGSFullscreenActivity, Bitmap paramBitmap)
  {
  }

  public final void run()
  {
    View localView = GSFullscreenActivity.b(this.b).getRootView();
    bd.b("v1 width " + localView.getWidth() + " h " + localView.getHeight(), new Object[0]);
    Bitmap localBitmap1 = Bitmap.createBitmap(localView.getWidth(), localView.getHeight(), Bitmap.Config.ARGB_8888);
    localView.draw(new Canvas(localBitmap1));
    bd.b("pagebmp: w " + localBitmap1.getWidth() + " h " + localBitmap1.getHeight(), new Object[0]);
    localView.setDrawingCacheEnabled(true);
    Bitmap localBitmap2 = localView.getDrawingCache();
    if (localBitmap2 == null)
      bd.b("wth screencache is null", new Object[0]);
    Bitmap localBitmap3 = Bitmap.createBitmap(localBitmap2);
    localView.setDrawingCacheEnabled(false);
    bd.b("screenshot w " + localBitmap3.getWidth() + " h " + localBitmap3.getHeight(), new Object[0]);
    DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    this.b.getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
    int i = localDisplayMetrics.heightPixels;
    int j = localDisplayMetrics.widthPixels;
    bd.b("screen w " + j + " h " + i, new Object[0]);
    Bitmap localBitmap4 = Bitmap.createScaledBitmap(this.a, localBitmap3.getWidth(), localBitmap3.getHeight(), true);
    int k;
    if (localBitmap4.getWidth() > localBitmap3.getWidth())
    {
      k = localBitmap4.getWidth();
      if (localBitmap4.getHeight() <= localBitmap3.getHeight())
        break label486;
    }
    label486: for (int m = localBitmap4.getHeight(); ; m = localBitmap3.getHeight())
    {
      bd.b("composition: w " + k + " h " + m, new Object[0]);
      Bitmap localBitmap5 = Bitmap.createBitmap(k, m, Bitmap.Config.ARGB_8888);
      Canvas localCanvas = new Canvas(localBitmap5);
      localCanvas.drawBitmap(localBitmap4, new Matrix(), null);
      localCanvas.drawBitmap(localBitmap3, new Matrix(), null);
      if (MediaStore.Images.Media.insertImage(this.b.getContentResolver(), localBitmap5, "", "") != null)
      {
        this.b.sendBroadcast(new Intent("android.intent.action.MEDIA_MOUNTED", Uri.parse("file://" + Environment.getExternalStorageDirectory())));
        GSFullscreenActivity.c(this.b).f();
      }
      return;
      k = localBitmap3.getWidth();
      break;
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.greystripe.sdk.ba
 * JD-Core Version:    0.6.2
 */